//
//  OldPhotoMainVipView.m
#import "OldPhotoMainVipView.h"
@interface OldPhotoMainVipView()
@property (nonatomic,strong) UILabel *oldPhotoMainVipNameLab;
@property (nonatomic,strong) UILabel *oldPhotoMainVipTitleLab;
@property (nonatomic,strong) UIButton *oldPhotoMainOpenVipBtn;
@end
@implementation OldPhotoMainVipView
-(instancetype)init{
    if (self == [super init]) {
        [self creatOldPhotoSubView];
    }
    return self;
}
- (void)creatOldPhotoSubView{
    UIImageView * oldPhotoMainVipImgBgView = [[UIImageView alloc] init];
    oldPhotoMainVipImgBgView.userInteractionEnabled = true;
    oldPhotoMainVipImgBgView.image = OldPhotoImageNamed(@"OldPhotoMainVipBg");
    [self addSubview:oldPhotoMainVipImgBgView];
    [oldPhotoMainVipImgBgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(@(OldPhotoRatio(0)));
    }];
    self.oldPhotoMainVipNameLab = [[UILabel alloc] init];
    self.oldPhotoMainVipNameLab.textColor = OldPhotoHex(@"#562D0B");
    self.oldPhotoMainVipNameLab.font = [UIFont systemFontOfSize:OldPhotoRatio(38) weight:UIFontWeightRegular];
    [oldPhotoMainVipImgBgView addSubview:self.oldPhotoMainVipNameLab];
    [self.oldPhotoMainVipNameLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(OldPhotoRatio(31)));
        make.top.equalTo(@(OldPhotoRatio(51)));
        make.height.equalTo(@(OldPhotoRatio(50)));
    }];
    self.oldPhotoMainVipTitleLab = [[UILabel alloc] init];
    self.oldPhotoMainVipTitleLab.textColor = OldPhotoHex(@"#562D0B");
    self.oldPhotoMainVipTitleLab.font = [UIFont systemFontOfSize:OldPhotoRatio(24) weight:UIFontWeightRegular];
    [oldPhotoMainVipImgBgView addSubview:self.oldPhotoMainVipTitleLab];
    [self.oldPhotoMainVipTitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(OldPhotoRatio(31)));
        make.top.equalTo(self.oldPhotoMainVipNameLab.mas_bottom).offset(OldPhotoRatio(14));
        make.height.equalTo(@(OldPhotoRatio(34)));
    }];
    self.oldPhotoMainOpenVipBtn = [[UIButton alloc] init];
    [self.oldPhotoMainOpenVipBtn setBackgroundImage:OldPhotoImageNamed(@"OldPhotoMainOpenVipBg") forState:UIControlStateNormal];
    [self.oldPhotoMainOpenVipBtn addTarget:self action:@selector(oldPhotoMainOpenVip) forControlEvents:UIControlEventTouchUpInside];
    [oldPhotoMainVipImgBgView addSubview:self.oldPhotoMainOpenVipBtn];
    [self.oldPhotoMainOpenVipBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(@(-OldPhotoRatio(30)));
        make.centerY.equalTo(oldPhotoMainVipImgBgView);
        make.width.equalTo(@(OldPhotoRatio(144)));
        make.height.equalTo(@(OldPhotoRatio(58)));
    }];
    [self oldPhotoUpdataVip];
}
- (void)oldPhotoMainOpenVip{
    if(self.OldPhotoMainOpenVipBlock){
        self.OldPhotoMainOpenVipBlock();
    }
}
- (void)oldPhotoUpdataVip{
//    if ([oldPhotoHead isoldPhotoVip]) {
//        self.oldPhotoMainVipNameLab.text = @"你已是会员";
//        self.oldPhotoMainOpenVipBtn.hidden = true;
//        
//        NSTimeInterval oldPhotoVipBuyTime = (NSTimeInterval)[[NSUserDefaults standardUserDefaults] doubleForKey:@"oldPhotoVipBuyTime"];
//        NSDate *oldPhotoVipBuyTimeDate = [NSDate dateWithTimeIntervalSince1970:oldPhotoVipBuyTime];
//        NSDateFormatter *oldPhotoVipBuyTimeDateDateFormat = [[NSDateFormatter alloc] init];
//        [oldPhotoVipBuyTimeDateDateFormat setDateFormat:@"yyyy-MM-dd HH:mm:ss"]; // 设置日期格式
//        // 格式化日期并输出
//        NSString *oldPhotoVipBuyTimeCurTime = [oldPhotoVipBuyTimeDateDateFormat stringFromDate:oldPhotoVipBuyTimeDate];
//        self.oldPhotoMainVipTitleLab.text = [NSString stringWithFormat:@"会员有效期至:%@",oldPhotoVipBuyTimeCurTime];
//    }else{
//        self.oldPhotoMainVipNameLab.text = @"开通会员";
//        self.oldPhotoMainVipTitleLab.text = @"享受所有会员权益  体验翻倍";
//        self.oldPhotoMainOpenVipBtn.hidden = false;
//    }
}
@end
